<template>
    <div class="">
        <!-- 头部导航栏 -->
        <div class="head">
            <h3>食谱秀网</h3>
            <svg class="icon icon-caidan" aria-hidden="true" @click="show = !show">
                <use xlink:href="#icon-caidan"></use>
            </svg>
            <!-- 头部隐藏栏 -->
            <transition name="fade">
                <ul class="tab" v-if="!show">
                    <router-link to="/index">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-icons_statistics"></use>
                                </svg>
                                首页
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/classify">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                食材分类
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/Cookbook">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                菜谱大全
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/HomeCooked">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                家常菜谱
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/restriction">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-star"></use>
                                </svg>
                                食物相克
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/PregnantDiet">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                孕妇食谱
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/FoodInformation">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                美食资讯
                            </span>
                        </li>
                    </router-link>
                </ul>
            </transition>
        </div>
        <!-- 搜索 -->
        <div class="sousuo">
            <svg class="icon icon-fangdajing" aria-hidden="true">
                <use xlink:href="#icon-fangdajing1"></use>
            </svg>
            <input type="text" class="sousuo1">
            <router-link to="/search">
                <input type="submit"  class="sousuo2" value="搜索">
            </router-link>
        </div>
        <!-- 推荐阅读 -->
        <ul class="reading">
            <li v-for="(item,index) in reading.slice(0,20)" :key="index">
                <router-link to="/Cookbook">
                    <img :src="item.src" alt="">
                    <h4>{{item.title}}</h4>
                    <p>{{item.content}}
                        <span>{{item.date}}</span>
                    </p>
                </router-link>
            </li>
        </ul>
        <!-- 按钮切换 -->
        <div class="change">
            <button>首页</button>
            <button>上一页</button>
            <button>下一页</button>
            <button>尾页</button>
        </div>
        <!-- 底部 -->
        <div class="foot">
            Copyright 食谱秀 m.shipuxiu.com <br>
            <p> 
                官方微信号: <span style="color: #ff0000;">chaoliu1588 </span> 
                <router-link to="https://m.shipuxiu.com/fenlei/">食谱分类</router-link>
                <router-link to="https://support.qq.com/products/113359/">我要吐槽</router-link>
                <router-link to="https://new.cnzz.com/v1/login.php?siteid=5433565">站长统计 </router-link>
             </p> 
        </div>
    </div>
    
</template>
<script>
export default {
    data(){
        return{
            show:true,
            reading:[]
        }
    },
    mounted(){
        // 获取数据
        this.$http.get('../../data/data.json')
        .then((response)=> {
            this.reading = response.data.reading
        })
        .catch(function (error) {
            console.log(error);
        })
        .then(function () {
            // always executed
        });
    }
}
</script>

<style scoped>
    /* 推荐阅读 */
    .reading{
        margin-top: 10px;
        width: 100%;
    }
    .reading li:nth-of-type(1){
        border-top: 2px solid #e8e8e8;
    }
    .reading li{
        width: 100%;
        height: 9vh;
        border-top: 1px solid #e8e8e8;
        padding-top: 16px;
    }
    .reading li img{
        width: 22vw;
        height: 8vh;
        float: left;
    }
    .reading li h4{
        display: block;
        width: 73vw;
        height: 3vh;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space: nowrap;
        font-size: 16px;
        color: #000000;
        float: right;
        padding-right: 10px;
    }
    .reading li p{
        color: #7b7b7b;
        font-size: 12px;
        float: left;
        width: 70vw;
        height: 12vh;
        padding-left: 10px;
        padding-top: 5px;
    }
    .reading li p span{
        float: right;
    }
    /* 按钮切换 */
    .change{
        width: 100%;
        line-height: 8vh;
        background: #f5f5f5;
        text-align: center;
    }
    .change button{
        width: 15vw;
        height: 4vh;
        background: #ee4e4e;
        font-size: 14px;
        color: #ffffff;
        border: none;
        margin-right: 5px;
    }
    .change button:nth-of-type(1),.change button:nth-of-type(4){
        width: 12vw;
    }
</style>